package com.zsh.wx_account1.controller;

import com.zsh.wx_account1.util.HttpUtil;
import com.zsh.wx_account1.util.TokenUtil;
import org.junit.jupiter.api.Test;

import java.net.HttpCookie;

/**
 * 用户账号管理
 * @Author ZhaoShuHao
 * @Date 2023/8/25 13:25
 */
public class TestAccountManagement {
    //生成带参数的二维码
    @Test
    public void testQRcode(){
        String url = String.format(" https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s",
                TokenUtil.getAccessToken());
        String data = "{\"expire_seconds\": 604800, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": 123}}}";
        String s = HttpUtil.doPost(url, data, "application/x-www-form-urlencoded");
        System.out.println(s);
    }
    /*
    https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=TICKET
    * https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEA8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyeW1TVFVPaUJkSUMxVFhTTk5BMVkAAgR7POhkAwSAOgkA
     * */
    //通过ticket换取二维码
    @Test
    public void testGetQRcode(){
        String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEA8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyeW1TVFVPaUJkSUMxVFhTTk5BMVkAAgR7POhkAwSAOgkA";
        String s = HttpUtil.doGet(url);
        System.out.println(s);
    }
}
